<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css"> /* <![CDATA[ */
  @import "tigris-branding/css/tigris.css";
  @import "tigris-branding/css/inst.css";
  /* ]]> */</style>
<link rel="stylesheet" type="text/css" media="print"
  href="tigris-branding/css/print.css"/>
<script type="text/javascript" src="tigris-branding/scripts/tigris.js"></script>
<title>cvs2git Documentation</title>
</head>

<body id="bodycol">
<div class="app">

<h1>cvs2git</h1>

<h2>Index</h2>

<ul>

  <li><a href="#intro">Introduction</a></li>

  <li><a href="#reqs">Requirements</a></li>

  <li><a href="#status">Development status</a></li>

  <li><a href="#docs">Documentation</a></li>

  <li><a href="#usage">Usage</a></li>

</ul>

<hr />

<h2><a name="intro">Introduction</a></h2>

<p>cvs2svn/cvs2git is a tool that can be used to migrate CVS
repositories to newer version control tools, including <a
href="http://git.or.cz/">git</a>.  git is a distributed version
control system most famous for being used for Linux kernel
development.  The program used to convert to git, called cvs2git, is
distributed as part of the cvs2svn project.</p>

<p><strong>If you are reading this documentation on the <a
href="http://cvs2svn.tigris.org">cvs2svn website</a>, then please be
aware that it describes the current trunk version of cvs2svn, which
may be different than the most recent released version.  Please refer
to the documentation that was included with your version of cvs2svn.
</strong></p>

<p>Conversion to git was added in release 2.1 of cvs2svn and has
improved significantly since then.  Please make sure you are using an
up-to-date version of cvs2svn--perhaps even the development trunk
version.</p>


<h2><a name="reqs">Requirements</a></h2>

<p>cvs2git requires the following:</p>

<ul>

  <li>Direct (filesystem) access to a copy of the CVS repository that
    you want to convert.  cvs2git parses the files in the CVS
    repository directly, so it is not enough to have remote CVS
    access.  See the <a href="faq.html#repoaccess">FAQ</a> for more
    information and a possible workaround.</li>

  <li>Python 2, version 2.4 or later.  See <a
    href="http://www.python.org/">http://www.python.org/</a>.
    (cvs2git does <strong>not</strong> work with Python 3.x.)</li>

  <li>If you use the <tt>--use-rcs</tt> option, then RCS's `co'
    program is required.  The RCS home page is
    <a href="http://www.cs.purdue.edu/homes/trinkle/RCS/"
            >http://www.cs.purdue.edu/homes/trinkle/RCS/</a>.
    See the <a href="cvs2svn.html#use-rcs"><tt>--use-rcs</tt> flag</a> for more
    details.</li>

  <li>If you use the <tt>--use-cvs</tt> option, then the `cvs' command
    is required.  The CVS home page is
    <a href="http://ccvs.cvshome.org/">http://ccvs.cvshome.org/</a>.
    See the <a href="cvs2svn.html#use-cvs"><tt>--use-cvs</tt> flag</a> for more
    details.</li>

  <li> Git version 1.5.4.4 or later (earlier versions have a bug in
    "git fast-import" that prevent them from loading the files
    generated by cvs2git).</li>

</ul>


<h2><a name="status">Development status</a></h2>

<p>Most of the work of converting a repository from CVS to a more
modern version control system is inferring the most likely history
given the incomplete information that CVS records.  cvs2svn has a long
history of making sense of even the most convoluted CVS repositories,
and cvs2git uses this same machinery.  Therefore, cvs2git inherits the
robustness and many of the <a href="features.html">features of
cvs2svn</a>.  cvs2svn can convert just about every CVS repository we
have ever seen, and includes a plethora of options for customizing
your conversion.</p>

<p>The output of cvs2git is one or more dump files that can be
imported into git using the excellent <a
href="http://www.kernel.org/pub/software/scm/git/docs/git
fast-import.html">git fast-import</a> tool.</p>

<p>Although cvs2git is considerably newer than cvs2svn, and much less
well tested, it is believed that cvs2git can be used for production
conversions.  If you use cvs2git, please let us know how it worked for
you!</p>


<h2><a name="limitations">cvs2git limitations</a></h2>

<p>cvs2git still has many limitations compared to
cvs2svn.  <strong>Help would be much appreciated!</strong> Some of
these missing features would be pretty easy to program, and I'd be
happy to help you get started.</p>

<ul>

  <li>The cvs2git documentation is still not as complete as that for
    cvs2svn.  See <a href="#docs">below</a> for more references.</li>

  <li>Differences between CVS and git branch/tag models: CVS allows a
    branch or tag to be created from arbitrary combinations of source
    revisions from multiple source branches.  It even allows file
    revisions that were never contemporaneous to be added to a single
    branch/tag.  Git, on the other hand, only allows the full source
    tree, as it existed at some instant in the history, to be branched
    or tagged as a unit.  Moreover, the ancestry of a git revision
    makes <a
    href="http://softwareswirl.blogspot.com/2009/08/git-mercurial-and-bazaarsimplicity.html">implications
    about the contents of that revision</a>.  This difference means
    that it is fundamentally impossible to represent an arbitrary CVS
    history in a git repository 100% faithfully.  cvs2git uses the
    following workarounds:

    <ul>

      <li>cvs2git tries to create a branch from a single source, but
        if it can't figure out how to, it creates the branch using a
        "merge" from multiple source branches.  In pathological
        situations, the number of merge sources for a branch can be
        arbitrarily large.  The resulting history implies that
        whenever any file was added to a branch, the <em>entire</em>
        source branch was merged into the destination branch, which is
        clearly incorrect.  (The alternative, to omit the merge, would
        discard the information that <em>some</em> content was moved
        from one branch to the other.)</li>

      <li>If cvs2git cannot determine that a CVS tag can be created
        from a single revision, then it creates a <a
        href="http://www.kernel.org/pub/software/scm/git/docs/git-fast-import.html">tag
        fixup branch</a> named <tt>TAG.FIXUP</tt>, then tags this
        branch.  (This is a necessary workaround for the fact that git
        only allows existing revisions to be tagged.)  The
        <tt>TAG.FIXUP</tt> branch is created as a merge between all of
        the branches that contain file revisions included in the tag,
        which involves the same tradeoff described above for branches.
        The <tt>TAG.FIXUP</tt> branch is cleared at the end of the
        conversion, but (due to a technical limitation of the git
        fast-import file format) not deleted.  There are some
        situations when a tag <em>could</em> be created from a single
        revision, but cvs2git does not realize it and creates a
        superfluous tag fixup branch.  It is possible to delete
        superfluous tag fixup branches after the conversion by running
        the <tt>contrib/git-move-refs.py</tt> script within the
        resulting git repository.</li>

    </ul>

  </li>

  <li>There are no checks that CVS branch and tag names are legal git
    names.  There are probably other git constraints that should also
    be checked.</li>

  <li>The data that should be fed to git fast-import are written to
    two files, which have to be loaded into git fast-import manually.
    These files might grow to very large size.  It would be nice to
    add an option to invoke git fast-import automatically and pipe the
    output directly into git fast-import; this should also speed up
    the conversion.</li>

  <li>Only single projects can be converted at a time.  Given the way
    git is typically used, this is probably what you want anyway.</li>

  <li>The cvs2svn test suite does not include meaningful tests of git
    output.</li>

  <li>cvs2git makes no attempt to convert <tt>.cvsignore</tt> files
    into <tt>.gitignore</tt> files.</li>

  <li>cvs2git, like cvs2svn, does not support incremental conversion
    (i.e., tracking a live CVS repository).  However, at least one
    person has documented a <a
    href="http://www.oak.homeunix.org/~marcel/blog/2009/06/03/tracking-cvs-with-git-using-cvs2git">possible
    workaround</a>.</li>

</ul>


<h2><a name="docs">Documentation</a></h2>

<p>There is some documentation specific to cvs2git, and much of the
cvs2svn documentation also applies fairly straightforwardly to
cvs2git.  See the following sources:</p>

<ul>

  <li>This document.</li>

  <li>The output of <tt>cvs2git --help</tt>.</li>

  <li>The cvs2git man page.  If the man page is not installed on your
    Unix-like system, you can view it by typing a command like
    <tt>cvs2git --man | groff -man -Tascii | less</tt>.</li>

  <li><a href="cvs2svn.html#intro">The cvs2svn documentation</a> and
    <a href="faq.html">the cvs2svn FAQ</a>, which contain much general
    discussion and describe many features that can also be used for
    cvs2git.</li>

  <li><tt>cvs2git-example.options</tt> in the cvs2svn source tree,
    which is an example of an options file that can be used to
    configure a cvs2git conversion.  The file is extensively
    documented.</li>

  <li>The cvs2svn mailing lists, IRC channel, etc., as described in <a
    href="faq.html#gettinghelp">the cvs2svn FAQ</a>.</li>

</ul>


<h2><a name="usage">Usage</a></h2>

<p>This section outlines the steps needed to convert a CVS repository
to git using cvs2git.</p>

<ol>

  <li>Be sure that you have the <a href="#reqs">requirements</a>,
    including either RCS or CVS (used to read revision contents from
    the CVS repository).</li>

  <li>Obtain a copy of cvs2svn/cvs2git version 2.1 or newer.  It is
    recommended that you use the most recent version available, or
    even the development version.

    <ul>

      <li>To install cvs2svn from a <a
        href="http://cvs2svn.tigris.org/servlets/ProjectDocumentList">tarball</a>,
        simply unpack the tarball into a directory on your conversion
        computer; cvs2git can be run directly from this
        directory.</li>

      <li>

        <p>To check out the current trunk version of cvs2svn, make
          sure that you have Subversion installed and then run:</p>

<pre>
svn co --username=guest --password="" http://cvs2svn.tigris.org/svn/cvs2svn/trunk cvs2svn-trunk
cd cvs2svn-trunk
make man # If you want to create manpages for the main programs
make check # ...optional
</pre>

        <p>Please note that the test suite includes tests that are
          marked "XFAIL" (expected failure); these are known and are
          not considered serious problems.</p>

      </li>

    </ul>

  </li>

  <li>

    Configure cvs2git and run the conversion.  This can be done via
    command-line options or via an options file:

    <ul>

      <li>

        <p>The command-line options for running cvs2git are documented
          in the cvs2git man page and in the output of <tt>cvs2git
          --help</tt>.  For example:</p>

<pre>
cvs2git \
    --blobfile=cvs2git-tmp/git-blob.dat \
    --dumpfile=cvs2git-tmp/git-dump.dat \
    --username=cvs2git \
    /path/to/cvs/repo
</pre>

      </li>

      <li>

        <p>The more flexible <a
          href="cvs2svn.html#cmd-vs-options">options-file method</a>
          requires you to create an options file, then start cvs2git
          with</p>

<pre>
cvs2git --options=OPTIONS-FILE
</pre>

        <p>Use <tt>cvs2git-example.options</tt> in the cvs2svn source
          tree as your starting point; the file contains lots of
          documentation.</p>

      </li>

    </ul>

    <p>This creates two output files
      in <a href="http://www.kernel.org/pub/software/scm/git/docs/git-fast-import.html">git
      fast-import</a> format.  The names of these files are specified
      by your options file or command-line arguments.  In the example,
      these files are named <tt>cvs2git-tmp/git-blob.dat</tt> and
      <tt>cvs2git-tmp/git-dump.dat</tt>.</p>

  </li>

  <li>

    <p>Initialize a git repository:</p>

<pre>
git init --bare /path/to/myproject.git
cd /path/to/myproject.git
</pre>

  </li>

  <li>

    <p>Load the dump files into the new git repository using <tt>git
      fast-import</tt>:</p>

<pre>
git fast-import --export-marks=../cvs2git-tmp/git-marks.dat &lt;../cvs2git-tmp/git-blob.dat
git fast-import --import-marks=../cvs2git-tmp/git-marks.dat &lt;../cvs2git-tmp/git-dump.dat
</pre>

    <p>On Linux/Unix this can be shortened to:</p>

<pre>
cat ../cvs2git-tmp/git-blob.dat ../cvs2git-tmp/git-dump.dat | git fast-import
</pre>

  </li>

  <li>

    <p>Delete the <tt>TAG.FIXUP</tt> branch:</p>

<pre>
git branch -D TAG.FIXUP
</pre>

  </li>

  <li>

    <p>(Optional) View the results of the conversion, for example:</p>

<pre>
gitk --all
</pre>

  </li>

  <li>(Recommended) To get rid of unnecessary tag fixup branches, run
    the <tt>contrib/git-move-refs.py</tt> script from within the git
    repository.</li>

  <li>

    <p>(Recommended) Re-compact the repository and discard any
      garbage:</p>

<pre>
git gc --prune=now
</pre>

  </li>

  <li>

    <p>The result of the above procedure is a <em>bare</em> git
      repository (one that does not have a checked-out version of the
      source tree).  This is the type of repository that you would put
      on your server.  To work on your project, make a non-bare clone
      (one that includes a checked-out source tree):</p>

<pre>
cd $HOME
git clone /path/to/myproject.git
cd myproject
</pre>

    <p>Now you are ready to start editing files and committing to
      git!</p>

  </li>

</ol>

<h2><a name="non-bare">Converting to a non-bare repository</a></h2>

<p>If you want to convert into a non-bare git repository (one
  that includes a working tree), then you need to make two changes to
  the above procedure:</p>

<ul>

  <li><p>Omit the <tt>--bare</tt> option in step 4; i.e., type</p>

<pre>
git init /path/to/myproject.git
cd /path/to/myproject.git
</pre>

  </li>

  <li><p>When the conversion is done, instead of cloning as described
    in step 10, you need to explicitly check out the "master" version
    of the files into your working tree:</p>

<pre>
git checkout master
</pre>

  </li>

</ul>

<p>Feedback would be much appreciated, including reports of success
  using cvs2git.  Please send comments, bug reports, and patches to
  the <a
  href="http://cvs2svn.tigris.org/servlets/ProjectMailingListList">cvs2svn
  mailing lists</a>.</p>

</div>
</body>
</html>
